using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CMS.BLL;
using CMS.BLL.Entity;

public partial class Admin_Contact_ContactAdd : System.Web.UI.UserControl
{
    private int nDefaultLang = Support.GetDefaultLanguage();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitData();
            SetLable();
        }
    }
    private void SetLable()
    {
        lblAdults.Text = MultipleLanguage.LBLADULT[nDefaultLang - 1];
        lblChildren.Text = MultipleLanguage.LBLCHILD[nDefaultLang - 1];
        lblContactDate.Text = MultipleLanguage.LBL_CREATEDDATE[nDefaultLang - 1];
        lblCountry.Text = MultipleLanguage.LBL_COUNTRY[nDefaultLang - 1];
        lblEmail.Text = MultipleLanguage.EMAIL[nDefaultLang - 1];
        lblFullName.Text = MultipleLanguage.LBL_FULLNAME[nDefaultLang - 1];
        lblNumberOFTraveller.Text = MultipleLanguage.LBL_NUMBEROFTRAVELLERS[nDefaultLang - 1];
        lblTelephone.Text = MultipleLanguage.TELEPHONE[nDefaultLang - 1];
        lblTravelDate.Text = MultipleLanguage.LBL_TRAVELDATE[nDefaultLang - 1];
        lblQuestion.Text = MultipleLanguage.LBL_MESSAGE[nDefaultLang - 1];
    }
    private void InitData()
    {
        int nItemID = ConvertData.ConvertToInt(Request.QueryString[Config.ACTION_ID]);
        string URL = Config.ROOT + Pages.BackEnds.ADMIN + "?" + Config.PAGE + "=" + Pages.BackEnds.STR_CONTACT;
        try
        {
            if (nItemID > 0)
            {
                Contacts  objContactUs = new Contacts();
                objContactUs.LoadById(nItemID);
                lblValEmail.Text = ConvertData.ConvertToString(objContactUs.Data.Email);
                lblValFullName.Text = objContactUs.Data.Fullname;
                lblValTelephone.Text = objContactUs.Data.Telephone;
                lblMainContent.Text = objContactUs.Data.MainContent;
                lblValContactDate.Text = ConvertData.ConvertIntToDatetimeString(objContactUs.Data.CreatedDate);
                lblValAdults.Text = ConvertData.ConvertToString(objContactUs.Data.Adult);
                lblValChildren.Text = ConvertData.ConvertToString(objContactUs.Data.Children);

                CustomerCountry objCountry = new CustomerCountry();
                if(objContactUs.Data.CountryID>0)
                    objCountry.LoadById(objContactUs.Data.CountryID);
                switch(nDefaultLang)
                {
                    case 1:
                        lblValCountry.Text = objCountry.Data.CountryName1;
                        break;
                        
                    case 2:
                    lblValCountry.Text = objCountry.Data.CountryName2;
                    break;
                        
                    case 3:
                    lblValCountry.Text = objCountry.Data.CountryName3;
                    break;
                }
                lblValNumberOFTraveller.Text = ConvertData.ConvertToString(objContactUs.Data.NumberOfTraellers);
                lblValTravelDate.Text = ConvertData.ConvertIntToDatetimeString(objContactUs.Data.TravelDate);
                int Result = objContactUs.UpdateStatus(nItemID, EnumeType.ACTIVE);
            }
            else
            { Response.Redirect(URL); }
        }
        catch
        {
            Response.Redirect(URL);
        }

    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        string URL = Config.ROOT + Pages.BackEnds.ADMIN + "?" + Config.PAGE + "=" + Pages.BackEnds.STR_CONTACT;
        Response.Redirect(URL);
    }
}
